﻿using AutoMapper;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using ProductionManage.Models.DataModel;
using ProductionManage.Models.Products;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using wangyaxin.Zhangduo;
using wangyaxin.Zhangduo.WorkShops;
using wangyaxin.Zhangduo.WorkShops.Dto;

namespace wangyaxin.Web.ZdController
{
    public class WorkShopController : Controller
    {
        private readonly IWorkShopAppService _service;
        public WorkShopController(IWorkShopAppService service)
        {
            _service = service;
        }

        public IActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 显示工作车间
        /// </summary>
        /// <returns></returns>
        public IActionResult ShowWorkShop()
        {
            return View();
        }
        /// <summary>
        /// 添加工作车间
        /// </summary>
        /// <returns></returns>

        public IActionResult AddWorkShop()
        {
            return View();
        }
        /// <summary>
        /// 反填工作车间
        /// </summary>
        /// <returns></returns>
        public IActionResult GetWorkShop(int id)
        {
            return View(id);
        }
        /// <summary>
        /// 显示车间信息
        /// </summary>
        /// <param name="WorkShopCode">编号</param>
        /// <param name="WorkShopName">名称</param>
        /// <returns>返回车间</returns>
        public Task<string> GetWorkShoppService(string? WorkShopCode, string? WorkShopName)
        {
            var WorkShops=_service.GetWorkShoppService(WorkShopCode, WorkShopName);
            return WorkShops;
        }
        /// <summary>
        /// 添加车间信息
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns>返回受影响行数</returns>
        [HttpGet]
        public Task<string> AddWorkShoppService(WorkShop model)
        {
            var relust=_service.AddWorkShoppService(model);
            return relust;
        }
        /// <summary>
        /// 删除车间信息
        /// </summary>
        /// <param name="id">车间id</param>
        /// <returns>返回受影响行数</returns>
        [HttpGet]
        public Task<int> DelWorkShopp(int id)
        {
            var relust = _service.DelWorkShopp(id);
            return relust;
        }
        /// <summary>
        /// 获取单条车间信息
        /// </summary>
        /// <param name="id">车间id</param>
        /// <returns>返回单条车间信息</returns>
        [HttpGet]
        public Task<WorkShop> getWorkShopBy(int id)
        {
            var workShop =_service.getWorkShopBy(id);
            return workShop;
        }
        /// <summary>
        /// 修改车间信息
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns>返回受影响行数</returns>
        [HttpGet]
        public Task<int> UpdWorkShopBy(UpdateWorkShopDto model)
        {
            var relust=_service.UpdWorkShopBy(model);
            return relust;
        }
    }
}
